﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace DARE
{
    public class CStorableData : CComponentData
    {
        //public CStorable storable;
        public uint idOfGameObjectOfContainerComponent;
        public CVignetteData vignette;

        public override void FillDataStructure(object component)
        {
            base.FillDataStructure(component);
            if ((component as CStorable).ContainerComponent != null)
                idOfGameObjectOfContainerComponent = (component as CStorable).ContainerComponent.GameObject.ID;
            vignette = new CVignetteData();
            vignette.FillDataStructure((component as CStorable).Vignette);
        }

        //public override void FillFromDataStructure(ref CComponent component, CRender3D render, CHUDSystem hud)
        //{
        //    base.FillFromDataStructure(ref component, render, hud);

        //    CVignette vig = hud.GetElement(vignette.name) as CVignette;
        //    if (vig == null)
        //        vig = new CVignette(hud, null, vignette.name);
        //    vig.ClickedTexture = new CHudTexture();
        //    if (vignette.clickedTexture.m_bodyTexture != null)
        //        vig.ClickedTexture.Body = CResourceMgr.Load<Texture2D>(vignette.clickedTexture.m_bodyTexture);
        //    vig.ReleasedTexture = new CHudTexture();
        //    if (vignette.releasedTexture.m_bodyTexture != null)
        //        vig.ReleasedTexture.Body = CResourceMgr.Load<Texture2D>(vignette.releasedTexture.m_bodyTexture);
        //    (component as CStorable).Vignette = vig;
        //}

        public override void FillFromDataStructure(ref CComponent component, CRender3D render, CHUDSystem hud)
        {
            base.FillFromDataStructure(ref component, render, hud);

            CVignette vig = hud.GetElement(vignette.name) as CVignette;
            if (vig == null)
                vig = new CVignette(hud, null, vignette.name);
            vig.ClickedTexture = new CHudTexture();
            if (vignette.clickedTexture.m_bodyTexture != null)
                vig.ClickedTexture.Body = CResourceMgr.Load<Texture2D>(vignette.clickedTexture.m_bodyTexture);
            vig.ReleasedTexture = new CHudTexture();
            if (vignette.releasedTexture.m_bodyTexture != null)
                vig.ReleasedTexture.Body = CResourceMgr.Load<Texture2D>(vignette.releasedTexture.m_bodyTexture);
            (component as CStorable).Vignette = vig;
        }
    }
}
